﻿using Microsoft.AspNetCore.Mvc;
using MyDapperApi.Services;
using QYWXUpdate.DataModel;

namespace MyDapperApi.Controllers;

[ApiController]
[Route("api/[controller]")]
public class CommonController : ControllerBase
{
    private readonly IJwtTokenService _tokenService;

    public CommonController(IJwtTokenService tokenService)
    {
        _tokenService = tokenService;
    }
    /// <summary>
    /// 标准接口格式不对外使用
    /// </summary>
    /// <returns></returns>
    [HttpPost("CommonGet")]
    public IActionResult CommonGet()
    {
        var token = _tokenService.CreateToken();
        return Ok(token);
    }
    /// <summary>
    /// 检查这个token是否还在有效期内
    /// </summary>
    /// <param name="request"></param>
    /// <returns></returns>
    [HttpPost("CommonPost")]
    public IActionResult CommonPost(IdRequest request)
    {
        var res = _tokenService.CheckToken(request);
        return Ok(res);
    }
}